/**
 * Created by fangzehua on 2017/7/4.
 */
$(function () {

    $("#category_add").click(function () {
         window.location.href="doCategoryPage";

    });


    //菜单列表
    $('#categoryTableEvents').bootstrapTable({
        url: "categoryList",
        search: false,
        pagination: true,
        showRefresh: false,
        showToggle: false,
        showColumns: false,
        pageSize:15,
        height:600,
        iconSize: 'outline',
        toolbar: '#categoryTableEventsToolbar',
        columns:[{
                field: 'SerialNumber',
                title: '序号',
                width:60,
                formatter: function (value, row, index) {
                return index+1;
            }},
            {
                field:'cid',
                title:'ID',
                width:80
            },
            {
                field:'name',
                title:'名称',
                width:300
            },
            {
                field:'flag',
                title:'状态',
                width:80,
                formatter: function(value, row, index) {
                    if(row.flag == '0') {
                        return "<font color='#228b22'>正常</font>";
                    } else {
                        return "<font color='#dcdcdc'>停用</font>";
                    }
                }
            },
            {
                field:'nums',
                title:'分类商品数',
                width:80,
                formatter: function(value, row, index) {
                    if(row.nums ==0) {
                        return "--";
                    } else {
                        return value;
                    }
                }
            },
            {
                field:'orderno',
                title:'排序',
                width:80
            },
            {
                field:'action',
                title:'操作',
                formatter: function(value, row, index) {
                    return [
                        '<shiro:hasPermission name="admin:ordervip:update">'+
                        '<a class="edit ml10" href="javascript:void(0)" title="修改">'+
                        '<i class="glyphicon glyphicon-edit"></i></a></shiro:hasPermission>&nbsp;&nbsp;&nbsp;&nbsp;',
                        '<shiro:hasPermission name="admin:ordervip:plus">'+
                        '<a class="plus ml12" href="javascript:void(0)" title="参数">'+
                        '<i class="glyphicon glyphicon-plus"></i></a></shiro:hasPermission>&nbsp;&nbsp;&nbsp;&nbsp;',
                        '<shiro:hasPermission name="admin:ordervip:clear">'+
                        '<a class="delete ml12" href="javascript:void(0)" title="删除">'+
                        '<i class="glyphicon glyphicon-remove-circle"></i></a></shiro:hasPermission>'
                    ].join('');
                },    //紫色为添加图标（icon），插件：font-awesome，效果图见底部。
                events: {
                    'click .delete': function(e, value, row, index) {
                        toastr.warning("暂不支持刪除!");
                    },
                    'click .edit': function(e, value, row, index) {
                            window.location.href="doEditor/"+row.cid;
                    },'click .plus': function(e, value, row, index) {
                        window.location.href="categoryItem/"+row.cid+'/'+row.name;
                    }
                }
            },

        ]
    });



});

